//
//  STNewFeatureCell.m
//  OCVVeibo
//
//  Created by leergou on 16/7/24.
//  Copyright © 2016年 WhiteHouse. All rights reserved.
//

#import "STNewFeatureCell.h"

@interface STNewFeatureCell ()

@property (nonatomic,strong) UIImageView *imageView;

//@property (nonatomic,strong) UIButton *experienceButton;


@end

@implementation STNewFeatureCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

#pragma mark - 按钮点击
- (void)butClick{
    [[NSNotificationCenter defaultCenter] postNotificationName:STSwitchRootVCNotification object:@"welcome"];
}

#pragma mark - setupUI
- (void)setupUI{
    
    // 添加子控件
    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.experienceButton];
    
    // 添加约束
    [self.imageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.bottom.equalTo(self.contentView);
    }];
    
    [self.experienceButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self).offset(-80);
    }];
    
}

#pragma mark - lazy
- (UIImageView *)imageView{
    
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
    }
    return _imageView;
}

- (UIButton *)experienceButton{
    if (!_experienceButton) {
        _experienceButton = [[UIButton alloc] initWithTitle:@"欢迎光临" bgNorImg:@"new_feature_finish_button" bgHighImg:nil highlightedImg:nil normalImg:nil selectedImg:nil target:self action:@selector(butClick)];
        _experienceButton.hidden = YES;
        [_experienceButton sizeToFit];
    }
    return _experienceButton;
}

- (void)setIndex:(NSInteger)index{
    _index = index;
    NSString *imageName = [NSString stringWithFormat:@"new_feature_%ld",index + 1];
    self.imageView.image = [UIImage imageNamed: imageName];
}



@end
